package com.taikang.hmp.hbusiness.diabetes.measure.talk.service.impl;

import java.util.Date;
import java.util.List;

import com.taikang.framework.common.util.IDHelper;
import com.taikang.hmp.frame.common.datastructre.Dto;
import com.taikang.hmp.frame.common.datastructre.support.BaseDto;
import com.taikang.hmp.frame.common.service.impl.BaseServiceImpl;
import com.taikang.hmp.hbusiness.diabetes.measure.talk.service.ITalkService;

/** 
 * 咨询管理
 * author:qrp
 * time:2015年12月16日 上午9:50:38
 */
public class TalkServiceImpl extends BaseServiceImpl implements ITalkService{

	public List<Dto> getTalkList(Dto paramDto) {
		List<Dto> list = null;
		list = super.getNewDao().queryForList("talk_space.getTalkList", paramDto);
		return list;
	}

	public Dto getHealtherInfo(Dto paramDto) {
		String uid = paramDto.getAsString("uid");
		Dto dto = null;
		List<Dto> list = null;
		try {
			list =super.getNewDao().queryForList("talk_space.getHealtherInfo", uid);
		} catch (Exception e) {
			e.printStackTrace();
		}
		if(list.size()>0){
			dto=list.get(0);
		}
		return dto;
	}

	public boolean sendTalkInfo(Dto paramDto) {
		List<Dto> userinfo = super.getNewDao().queryForList("talk_space.getuserinfo", paramDto.getAsString("senduserid"));
		Dto dto = new BaseDto();
		dto.put("msg_id", IDHelper.genUUID());
		dto.put("message", paramDto.getAsString("content"));
		dto.put("msgsend_user", userinfo.get(0).getAsString("custom_id"));
		dto.put("receive_user", paramDto.getAsString("recieveuserid"));
		dto.put("send_time", paramDto.getAsString("bdate"));
		dto.put("state", "");
		dto.put("parent_id", "");
		dto.put("source_cd", "");
		dto.put("operater", "");
		dto.put("operate_date", new Date());
		if(userinfo.get(0).getAsString("customer_id").equals(paramDto.getAsString("recieveuserid"))){
			return false;
		}else{
			super.getNewDao().insert("talk_space.sendTalkInfo", dto);
			return true;
		}
	}
	
	public List<Dto> gethealtherInfo(String uid) {
		return super.getNewDao().queryForList("talk_space.getHealtherInfo", uid);
	}

}
